package com.Innovationstudio.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import test.EmailTest;

import com.Innovationstudio.web.controller.base.BaseController;
import com.Innovationstudio.web.pagemodel.RegisterData;
import com.Innovationstudio.web.util.SimpleSMTPSender;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.PostConstruct;
import javax.mail.MessagingException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;



@Controller
@RequestMapping("/account")
public class AccountController extends BaseController {
    @Autowired
    private ServletContext servletContext;

    private String contextRootPath;


    @PostConstruct
    public void afterPropertiesSet() {
        contextRootPath = servletContext.getRealPath("/");
    }

   

    @Transactional
    @RequestMapping(value = "/getcode",method = RequestMethod.GET )
    public void register(String email, Model model,HttpServletResponse response) {
    	System.out.println("/getcode");
    	System.out.println("email="+email);
    	boolean flag =false;    	
        if(EmailTest.sencode(email)) {
            String result = "{\"result\":\"error\"}";
			if(flag){
				result = "{\"result\":\"success\"}";
			}
			PrintWriter out = null;
			response.setContentType("application/json");			
			try {
				out = response.getWriter();
				out.write(result);
			} catch (IOException e) {
				e.printStackTrace();
			}
			out.close();
       }
   }
    
    @RequestMapping(value = "/toverityjsp")
   public String toverityjsp(){
	   System.out.println("/toverityjsp");
	   return "veritycode";
   }

   
}
